<?php
define("EW_PAGE_ID", "edit", TRUE); // Page ID
define("EW_TABLE_NAME", 'tb_dailygross_sales', TRUE);
?>
<?php 
session_start(); // Initialize session data
ob_start(); // Turn on output buffering
?>
<?php include "ewcfg50.php" ?>
<?php include "ewmysql50.php" ?>
<?php include "phpfn50.php" ?>
<?php include "tb_dailygross_salesinfo.php" ?>
<?php include "userfn50.php" ?>
<?php include "tb_usersinfo.php" ?>
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1 
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
?>
<?php

// Open connection to the database
$conn = ew_Connect();
?>
<?php
$Security = new cAdvancedSecurity();
?>
<?php
if (!$Security->IsLoggedIn()) $Security->AutoLogin();
if (!$Security->IsLoggedIn()) {
	$Security->SaveLastUrl();
	Page_Terminate("login.php");
}
?>
<?php

// Common page loading event (in userfn*.php)
Page_Loading();
?>
<?php

// Page load event, used in current page
Page_Load();
?>
<?php
$tb_dailygross_sales->Export = @$_GET["export"]; // Get export parameter
$sExport = $tb_dailygross_sales->Export; // Get export parameter, used in header
$sExportFile = $tb_dailygross_sales->TableVar; // Get export file, used in header
?>
<?php

// Load key from QueryString
if (@$_GET["ID"] <> "") {
	$tb_dailygross_sales->ID->setQueryStringValue($_GET["ID"]);
}

// Create form object
$objForm = new cFormObj();
if (@$_POST["a_edit"] <> "") {
	$tb_dailygross_sales->CurrentAction = $_POST["a_edit"]; // Get action code
	LoadFormValues(); // Get form values
} else {
	$tb_dailygross_sales->CurrentAction = "I"; // Default action is display
}

// Check if valid key
if ($tb_dailygross_sales->ID->CurrentValue == "") Page_Terminate($tb_dailygross_sales->getReturnUrl()); // Invalid key, exit
switch ($tb_dailygross_sales->CurrentAction) {
	case "I": // Get a record to display
		if (!LoadRow()) { // Load Record based on key
			$_SESSION[EW_SESSION_MESSAGE] = "No records found"; // No record found
			Page_Terminate($tb_dailygross_sales->getReturnUrl()); // Return to caller
		}
		break;
	Case "U": // Update
		$tb_dailygross_sales->SendEmail = TRUE; // Send email on update success
		if (EditRow()) { // Update Record based on key
			$_SESSION[EW_SESSION_MESSAGE] = "Update successful"; // Update success
			Page_Terminate($tb_dailygross_sales->getReturnUrl()); // Return to caller
		} else {
			RestoreFormValues(); // Restore form values if update failed
		}
}

// Render the record
$tb_dailygross_sales->RowType = EW_ROWTYPE_EDIT; // Render as edit
RenderRow();
?>
<?php include "header.php" ?>
<script type="text/javascript">
<!--
var EW_PAGE_ID = "edit"; // Page id

//-->
</script>
<script type="text/javascript">
<!--

function ew_ValidateForm(fobj) {
	if (fobj.a_confirm && fobj.a_confirm.value == "F")
		return true;
	var i, elm, aelm, infix;
	var rowcnt = (fobj.key_count) ? Number(fobj.key_count.value) : 1;
	for (i=0; i<rowcnt; i++) {
		infix = (fobj.key_count) ? String(i+1) : "";
		elm = fobj.elements["x" + infix + "_LocationId"];
		if (elm && !ew_CheckInteger(elm.value)) {
			if (!ew_OnError(elm, "Incorrect integer - Location Id"))
				return false; 
		}
		elm = fobj.elements["x" + infix + "_DateRange1"];
		if (elm && !ew_CheckDate(elm.value)) {
			if (!ew_OnError(elm, "Incorrect date, format = yyyy/mm/dd - Date Range 1"))
				return false; 
		}
		elm = fobj.elements["x" + infix + "_MedicaidAmount"];
		if (elm && !ew_CheckNumber(elm.value)) {
			if (!ew_OnError(elm, "Incorrect floating point number - Medicaid Amount"))
				return false; 
		}
		elm = fobj.elements["x" + infix + "_MedicaidRx"];
		if (elm && !ew_CheckNumber(elm.value)) {
			if (!ew_OnError(elm, "Incorrect floating point number - Medicaid Rx"))
				return false; 
		}
		elm = fobj.elements["x" + infix + "_EpicRx"];
		if (elm && !ew_CheckNumber(elm.value)) {
			if (!ew_OnError(elm, "Incorrect floating point number - Epic Rx"))
				return false; 
		}
		elm = fobj.elements["x" + infix + "_CheckLog"];
		if (elm && !ew_CheckNumber(elm.value)) {
			if (!ew_OnError(elm, "Incorrect floating point number - Check Log"))
				return false; 
		}
		elm = fobj.elements["x" + infix + "_PayRollAmount"];
		if (elm && !ew_CheckNumber(elm.value)) {
			if (!ew_OnError(elm, "Incorrect floating point number - Pay Roll Amount"))
				return false; 
		}
		elm = fobj.elements["x" + infix + "_KinaryAmount"];
		if (elm && !ew_CheckNumber(elm.value)) {
			if (!ew_OnError(elm, "Incorrect floating point number - Kinary Amount"))
				return false; 
		}
		elm = fobj.elements["x" + infix + "_CreateDate"];
		if (elm && !ew_CheckDate(elm.value)) {
			if (!ew_OnError(elm, "Incorrect date, format = yyyy/mm/dd - Create Date"))
				return false; 
		}
		elm = fobj.elements["x" + infix + "_DateRange2"];
		if (elm && !ew_CheckDate(elm.value)) {
			if (!ew_OnError(elm, "Incorrect date, format = yyyy/mm/dd - Date Range 2"))
				return false; 
		}
	}
	return true;
}

//-->
</script>
<script type="text/javascript">
<!--
var ew_DHTMLEditors = [];

//-->
</script>
<script type="text/javascript">
<!--
var ew_MultiPagePage = "Page"; // multi-page Page Text
var ew_MultiPageOf = "of"; // multi-page Of Text
var ew_MultiPagePrev = "Prev"; // multi-page Prev Text
var ew_MultiPageNext = "Next"; // multi-page Next Text

//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--

// Write your client script here, no need to add script tags.
// To include another .js script, use:
// ew_ClientScriptInclude("my_javascript.js"); 
//-->

</script>
<p><span class="phpmaker">Edit TABLE: Daily Gross Sales<br><br><a href="<?php echo $tb_dailygross_sales->getReturnUrl() ?>">Go Back</a></span></p>
<?php
if (@$_SESSION[EW_SESSION_MESSAGE] <> "") {
?>
<p><span class="ewmsg"><?php echo $_SESSION[EW_SESSION_MESSAGE] ?></span></p>
<?php
	$_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message
}
?>
<form name="ftb_dailygross_salesedit" id="ftb_dailygross_salesedit" action="tb_dailygross_salesedit.php" method="post" onSubmit="return ew_ValidateForm(this);">
<p>
<input type="hidden" name="a_edit" id="a_edit" value="U">
<table class="ewTable">
	<tr class="ewTableRow">
		<td class="ewTableHeader">ID</td>
		<td<?php echo $tb_dailygross_sales->ID->CellAttributes() ?>><span id="cb_x_ID">
<div<?php echo $tb_dailygross_sales->ID->ViewAttributes() ?>><?php echo $tb_dailygross_sales->ID->EditValue ?></div>
<input type="hidden" name="x_ID" id="x_ID" value="<?php echo ew_HtmlEncode($tb_dailygross_sales->ID->CurrentValue) ?>">
</span></td>
	</tr>
	<tr class="ewTableAltRow">
		<td class="ewTableHeader">Location Id</td>
		<td<?php echo $tb_dailygross_sales->LocationId->CellAttributes() ?>><span id="cb_x_LocationId">
<input type="text" name="x_LocationId" id="x_LocationId" title="" size="30" value="<?php echo $tb_dailygross_sales->LocationId->EditValue ?>"<?php echo $tb_dailygross_sales->LocationId->EditAttributes() ?>>
</span></td>
	</tr>
	<tr class="ewTableRow">
		<td class="ewTableHeader">Date Range 1</td>
		<td<?php echo $tb_dailygross_sales->DateRange1->CellAttributes() ?>><span id="cb_x_DateRange1">
<input type="text" name="x_DateRange1" id="x_DateRange1" title="" value="<?php echo $tb_dailygross_sales->DateRange1->EditValue ?>"<?php echo $tb_dailygross_sales->DateRange1->EditAttributes() ?>>
</span></td>
	</tr>
	<tr class="ewTableAltRow">
		<td class="ewTableHeader">Medicaid Amount</td>
		<td<?php echo $tb_dailygross_sales->MedicaidAmount->CellAttributes() ?>><span id="cb_x_MedicaidAmount">
<input type="text" name="x_MedicaidAmount" id="x_MedicaidAmount" title="" size="30" value="<?php echo $tb_dailygross_sales->MedicaidAmount->EditValue ?>"<?php echo $tb_dailygross_sales->MedicaidAmount->EditAttributes() ?>>
</span></td>
	</tr>
	<tr class="ewTableRow">
		<td class="ewTableHeader">Medicaid Rx</td>
		<td<?php echo $tb_dailygross_sales->MedicaidRx->CellAttributes() ?>><span id="cb_x_MedicaidRx">
<input type="text" name="x_MedicaidRx" id="x_MedicaidRx" title="" size="30" value="<?php echo $tb_dailygross_sales->MedicaidRx->EditValue ?>"<?php echo $tb_dailygross_sales->MedicaidRx->EditAttributes() ?>>
</span></td>
	</tr>
	<tr class="ewTableAltRow">
		<td class="ewTableHeader">Epic Rx</td>
		<td<?php echo $tb_dailygross_sales->EpicRx->CellAttributes() ?>><span id="cb_x_EpicRx">
<input type="text" name="x_EpicRx" id="x_EpicRx" title="" size="30" value="<?php echo $tb_dailygross_sales->EpicRx->EditValue ?>"<?php echo $tb_dailygross_sales->EpicRx->EditAttributes() ?>>
</span></td>
	</tr>
	<tr class="ewTableRow">
		<td class="ewTableHeader">Check Log</td>
		<td<?php echo $tb_dailygross_sales->CheckLog->CellAttributes() ?>><span id="cb_x_CheckLog">
<input type="text" name="x_CheckLog" id="x_CheckLog" title="" size="30" value="<?php echo $tb_dailygross_sales->CheckLog->EditValue ?>"<?php echo $tb_dailygross_sales->CheckLog->EditAttributes() ?>>
</span></td>
	</tr>
	<tr class="ewTableAltRow">
		<td class="ewTableHeader">Pay Roll Amount</td>
		<td<?php echo $tb_dailygross_sales->PayRollAmount->CellAttributes() ?>><span id="cb_x_PayRollAmount">
<input type="text" name="x_PayRollAmount" id="x_PayRollAmount" title="" size="30" value="<?php echo $tb_dailygross_sales->PayRollAmount->EditValue ?>"<?php echo $tb_dailygross_sales->PayRollAmount->EditAttributes() ?>>
</span></td>
	</tr>
	<tr class="ewTableRow">
		<td class="ewTableHeader">Kinary Amount</td>
		<td<?php echo $tb_dailygross_sales->KinaryAmount->CellAttributes() ?>><span id="cb_x_KinaryAmount">
<input type="text" name="x_KinaryAmount" id="x_KinaryAmount" title="" size="30" value="<?php echo $tb_dailygross_sales->KinaryAmount->EditValue ?>"<?php echo $tb_dailygross_sales->KinaryAmount->EditAttributes() ?>>
</span></td>
	</tr>
	<tr class="ewTableAltRow">
		<td class="ewTableHeader">Entered By</td>
		<td<?php echo $tb_dailygross_sales->EnteredBy->CellAttributes() ?>><span id="cb_x_EnteredBy">
<input type="text" name="x_EnteredBy" id="x_EnteredBy" title="" size="30" maxlength="32" value="<?php echo $tb_dailygross_sales->EnteredBy->EditValue ?>"<?php echo $tb_dailygross_sales->EnteredBy->EditAttributes() ?>>
</span></td>
	</tr>
	<tr class="ewTableRow">
		<td class="ewTableHeader">Create Date</td>
		<td<?php echo $tb_dailygross_sales->CreateDate->CellAttributes() ?>><span id="cb_x_CreateDate">
<input type="text" name="x_CreateDate" id="x_CreateDate" title="" value="<?php echo $tb_dailygross_sales->CreateDate->EditValue ?>"<?php echo $tb_dailygross_sales->CreateDate->EditAttributes() ?>>
</span></td>
	</tr>
	<tr class="ewTableAltRow">
		<td class="ewTableHeader">Date Range 2</td>
		<td<?php echo $tb_dailygross_sales->DateRange2->CellAttributes() ?>><span id="cb_x_DateRange2">
<input type="text" name="x_DateRange2" id="x_DateRange2" title="" value="<?php echo $tb_dailygross_sales->DateRange2->EditValue ?>"<?php echo $tb_dailygross_sales->DateRange2->EditAttributes() ?>>
</span></td>
	</tr>
</table>
<p>
<input type="submit" name="btnAction" id="btnAction" value="   Edit   ">
</form>
<script language="JavaScript" type="text/javascript">
<!--

// Write your table-specific startup script here
// document.write("page loaded");
//-->

</script>
<?php include "footer.php" ?>
<?php

// If control is passed here, simply terminate the page without redirect
Page_Terminate();

// -----------------------------------------------------------------
//  Subroutine Page_Terminate
//  - called when exit page
//  - clean up connection and objects
//  - if url specified, redirect to url, otherwise end response
function Page_Terminate($url = "") {
	global $conn;

	// Page unload event, used in current page
	Page_Unload();

	// Global page unloaded event (in userfn*.php)
	Page_Unloaded();

	 // Close Connection
	$conn->Close();

	// Go to url if specified
	if ($url <> "") {
		ob_end_clean();
		header("Location: $url");
	}
	exit();
}
?>
<?php

// Load form values
function LoadFormValues() {

	// Load from form
	global $objForm, $tb_dailygross_sales;
	$tb_dailygross_sales->ID->setFormValue($objForm->GetValue("x_ID"));
	$tb_dailygross_sales->LocationId->setFormValue($objForm->GetValue("x_LocationId"));
	$tb_dailygross_sales->DateRange1->setFormValue($objForm->GetValue("x_DateRange1"));
	$tb_dailygross_sales->DateRange1->CurrentValue = ew_UnFormatDateTime($tb_dailygross_sales->DateRange1->CurrentValue, 5);
	$tb_dailygross_sales->MedicaidAmount->setFormValue($objForm->GetValue("x_MedicaidAmount"));
	$tb_dailygross_sales->MedicaidRx->setFormValue($objForm->GetValue("x_MedicaidRx"));
	$tb_dailygross_sales->EpicRx->setFormValue($objForm->GetValue("x_EpicRx"));
	$tb_dailygross_sales->CheckLog->setFormValue($objForm->GetValue("x_CheckLog"));
	$tb_dailygross_sales->PayRollAmount->setFormValue($objForm->GetValue("x_PayRollAmount"));
	$tb_dailygross_sales->KinaryAmount->setFormValue($objForm->GetValue("x_KinaryAmount"));
	$tb_dailygross_sales->EnteredBy->setFormValue($objForm->GetValue("x_EnteredBy"));
	$tb_dailygross_sales->CreateDate->setFormValue($objForm->GetValue("x_CreateDate"));
	$tb_dailygross_sales->CreateDate->CurrentValue = ew_UnFormatDateTime($tb_dailygross_sales->CreateDate->CurrentValue, 5);
	$tb_dailygross_sales->DateRange2->setFormValue($objForm->GetValue("x_DateRange2"));
	$tb_dailygross_sales->DateRange2->CurrentValue = ew_UnFormatDateTime($tb_dailygross_sales->DateRange2->CurrentValue, 5);
}

// Restore form values
function RestoreFormValues() {
	global $tb_dailygross_sales;
	$tb_dailygross_sales->ID->CurrentValue = $tb_dailygross_sales->ID->FormValue;
	$tb_dailygross_sales->LocationId->CurrentValue = $tb_dailygross_sales->LocationId->FormValue;
	$tb_dailygross_sales->DateRange1->CurrentValue = $tb_dailygross_sales->DateRange1->FormValue;
	$tb_dailygross_sales->DateRange1->CurrentValue = ew_UnFormatDateTime($tb_dailygross_sales->DateRange1->CurrentValue, 5);
	$tb_dailygross_sales->MedicaidAmount->CurrentValue = $tb_dailygross_sales->MedicaidAmount->FormValue;
	$tb_dailygross_sales->MedicaidRx->CurrentValue = $tb_dailygross_sales->MedicaidRx->FormValue;
	$tb_dailygross_sales->EpicRx->CurrentValue = $tb_dailygross_sales->EpicRx->FormValue;
	$tb_dailygross_sales->CheckLog->CurrentValue = $tb_dailygross_sales->CheckLog->FormValue;
	$tb_dailygross_sales->PayRollAmount->CurrentValue = $tb_dailygross_sales->PayRollAmount->FormValue;
	$tb_dailygross_sales->KinaryAmount->CurrentValue = $tb_dailygross_sales->KinaryAmount->FormValue;
	$tb_dailygross_sales->EnteredBy->CurrentValue = $tb_dailygross_sales->EnteredBy->FormValue;
	$tb_dailygross_sales->CreateDate->CurrentValue = $tb_dailygross_sales->CreateDate->FormValue;
	$tb_dailygross_sales->CreateDate->CurrentValue = ew_UnFormatDateTime($tb_dailygross_sales->CreateDate->CurrentValue, 5);
	$tb_dailygross_sales->DateRange2->CurrentValue = $tb_dailygross_sales->DateRange2->FormValue;
	$tb_dailygross_sales->DateRange2->CurrentValue = ew_UnFormatDateTime($tb_dailygross_sales->DateRange2->CurrentValue, 5);
}
?>
<?php

// Load row based on key values
function LoadRow() {
	global $conn, $Security, $tb_dailygross_sales;
	$sFilter = $tb_dailygross_sales->SqlKeyFilter();
	if (!is_numeric($tb_dailygross_sales->ID->CurrentValue)) {
		return FALSE; // Invalid key, exit
	}
	$sFilter = str_replace("@ID@", ew_AdjustSql($tb_dailygross_sales->ID->CurrentValue), $sFilter); // Replace key value

	// Call Row Selecting event
	$tb_dailygross_sales->Row_Selecting($sFilter);

	// Load sql based on filter
	$tb_dailygross_sales->CurrentFilter = $sFilter;
	$sSql = $tb_dailygross_sales->SQL();
	if ($rs = $conn->Execute($sSql)) {
		if ($rs->EOF) {
			$LoadRow = FALSE;
		} else {
			$LoadRow = TRUE;
			$rs->MoveFirst();
			LoadRowValues($rs); // Load row values

			// Call Row Selected event
			$tb_dailygross_sales->Row_Selected($rs);
		}
		$rs->Close();
	} else {
		$LoadRow = FALSE;
	}
	return $LoadRow;
}

// Load row values from recordset
function LoadRowValues(&$rs) {
	global $tb_dailygross_sales;
	$tb_dailygross_sales->ID->setDbValue($rs->fields('ID'));
	$tb_dailygross_sales->LocationId->setDbValue($rs->fields('LocationId'));
	$tb_dailygross_sales->DateRange1->setDbValue($rs->fields('DateRange1'));
	$tb_dailygross_sales->MedicaidAmount->setDbValue($rs->fields('MedicaidAmount'));
	$tb_dailygross_sales->MedicaidRx->setDbValue($rs->fields('MedicaidRx'));
	$tb_dailygross_sales->EpicRx->setDbValue($rs->fields('EpicRx'));
	$tb_dailygross_sales->CheckLog->setDbValue($rs->fields('CheckLog'));
	$tb_dailygross_sales->PayRollAmount->setDbValue($rs->fields('PayRollAmount'));
	$tb_dailygross_sales->KinaryAmount->setDbValue($rs->fields('KinaryAmount'));
	$tb_dailygross_sales->EnteredBy->setDbValue($rs->fields('EnteredBy'));
	$tb_dailygross_sales->CreateDate->setDbValue($rs->fields('CreateDate'));
	$tb_dailygross_sales->DateRange2->setDbValue($rs->fields('DateRange2'));
}
?>
<?php

// Render row values based on field settings
function RenderRow() {
	global $conn, $Security, $tb_dailygross_sales;

	// Call Row Rendering event
	$tb_dailygross_sales->Row_Rendering();

	// Common render codes for all row types
	// ID

	$tb_dailygross_sales->ID->CellCssStyle = "";
	$tb_dailygross_sales->ID->CellCssClass = "";

	// LocationId
	$tb_dailygross_sales->LocationId->CellCssStyle = "";
	$tb_dailygross_sales->LocationId->CellCssClass = "";

	// DateRange1
	$tb_dailygross_sales->DateRange1->CellCssStyle = "";
	$tb_dailygross_sales->DateRange1->CellCssClass = "";

	// MedicaidAmount
	$tb_dailygross_sales->MedicaidAmount->CellCssStyle = "";
	$tb_dailygross_sales->MedicaidAmount->CellCssClass = "";

	// MedicaidRx
	$tb_dailygross_sales->MedicaidRx->CellCssStyle = "";
	$tb_dailygross_sales->MedicaidRx->CellCssClass = "";

	// EpicRx
	$tb_dailygross_sales->EpicRx->CellCssStyle = "";
	$tb_dailygross_sales->EpicRx->CellCssClass = "";

	// CheckLog
	$tb_dailygross_sales->CheckLog->CellCssStyle = "";
	$tb_dailygross_sales->CheckLog->CellCssClass = "";

	// PayRollAmount
	$tb_dailygross_sales->PayRollAmount->CellCssStyle = "";
	$tb_dailygross_sales->PayRollAmount->CellCssClass = "";

	// KinaryAmount
	$tb_dailygross_sales->KinaryAmount->CellCssStyle = "";
	$tb_dailygross_sales->KinaryAmount->CellCssClass = "";

	// EnteredBy
	$tb_dailygross_sales->EnteredBy->CellCssStyle = "";
	$tb_dailygross_sales->EnteredBy->CellCssClass = "";

	// CreateDate
	$tb_dailygross_sales->CreateDate->CellCssStyle = "";
	$tb_dailygross_sales->CreateDate->CellCssClass = "";

	// DateRange2
	$tb_dailygross_sales->DateRange2->CellCssStyle = "";
	$tb_dailygross_sales->DateRange2->CellCssClass = "";
	if ($tb_dailygross_sales->RowType == EW_ROWTYPE_VIEW) { // View row
	} elseif ($tb_dailygross_sales->RowType == EW_ROWTYPE_ADD) { // Add row
	} elseif ($tb_dailygross_sales->RowType == EW_ROWTYPE_EDIT) { // Edit row

		// ID
		$tb_dailygross_sales->ID->EditCustomAttributes = "";
		$tb_dailygross_sales->ID->EditValue = $tb_dailygross_sales->ID->CurrentValue;
		$tb_dailygross_sales->ID->CssStyle = "";
		$tb_dailygross_sales->ID->CssClass = "";
		$tb_dailygross_sales->ID->ViewCustomAttributes = "";

		// LocationId
		$tb_dailygross_sales->LocationId->EditCustomAttributes = "";
		$tb_dailygross_sales->LocationId->EditValue = $tb_dailygross_sales->LocationId->CurrentValue;

		// DateRange1
		$tb_dailygross_sales->DateRange1->EditCustomAttributes = "";
		$tb_dailygross_sales->DateRange1->EditValue = ew_FormatDateTime($tb_dailygross_sales->DateRange1->CurrentValue, 5);

		// MedicaidAmount
		$tb_dailygross_sales->MedicaidAmount->EditCustomAttributes = "";
		$tb_dailygross_sales->MedicaidAmount->EditValue = $tb_dailygross_sales->MedicaidAmount->CurrentValue;

		// MedicaidRx
		$tb_dailygross_sales->MedicaidRx->EditCustomAttributes = "";
		$tb_dailygross_sales->MedicaidRx->EditValue = $tb_dailygross_sales->MedicaidRx->CurrentValue;

		// EpicRx
		$tb_dailygross_sales->EpicRx->EditCustomAttributes = "";
		$tb_dailygross_sales->EpicRx->EditValue = $tb_dailygross_sales->EpicRx->CurrentValue;

		// CheckLog
		$tb_dailygross_sales->CheckLog->EditCustomAttributes = "";
		$tb_dailygross_sales->CheckLog->EditValue = $tb_dailygross_sales->CheckLog->CurrentValue;

		// PayRollAmount
		$tb_dailygross_sales->PayRollAmount->EditCustomAttributes = "";
		$tb_dailygross_sales->PayRollAmount->EditValue = $tb_dailygross_sales->PayRollAmount->CurrentValue;

		// KinaryAmount
		$tb_dailygross_sales->KinaryAmount->EditCustomAttributes = "";
		$tb_dailygross_sales->KinaryAmount->EditValue = $tb_dailygross_sales->KinaryAmount->CurrentValue;

		// EnteredBy
		$tb_dailygross_sales->EnteredBy->EditCustomAttributes = "";
		$tb_dailygross_sales->EnteredBy->EditValue = ew_HtmlEncode($tb_dailygross_sales->EnteredBy->CurrentValue);

		// CreateDate
		$tb_dailygross_sales->CreateDate->EditCustomAttributes = "";
		$tb_dailygross_sales->CreateDate->EditValue = ew_FormatDateTime($tb_dailygross_sales->CreateDate->CurrentValue, 5);

		// DateRange2
		$tb_dailygross_sales->DateRange2->EditCustomAttributes = "";
		$tb_dailygross_sales->DateRange2->EditValue = ew_FormatDateTime($tb_dailygross_sales->DateRange2->CurrentValue, 5);
	} elseif ($tb_dailygross_sales->RowType == EW_ROWTYPE_SEARCH) { // Search row
	}

	// Call Row Rendered event
	$tb_dailygross_sales->Row_Rendered();
}
?>
<?php

// Update record based on key values
function EditRow() {
	global $conn, $Security, $tb_dailygross_sales;
	$sFilter = $tb_dailygross_sales->SqlKeyFilter();
	if (!is_numeric($tb_dailygross_sales->ID->CurrentValue)) {
		return FALSE;
	}
	$sFilter = str_replace("@ID@", ew_AdjustSql($tb_dailygross_sales->ID->CurrentValue), $sFilter); // Replace key value
	$tb_dailygross_sales->CurrentFilter = $sFilter;
	$sSql = $tb_dailygross_sales->SQL();
	$conn->raiseErrorFn = 'ew_ErrorFn';
	$rs = $conn->Execute($sSql);
	$conn->raiseErrorFn = '';
	if ($rs === FALSE)
		return FALSE;
	if ($rs->EOF) {
		$EditRow = FALSE; // Update Failed
	} else {

		// Save old values
		$rsold =& $rs->fields;
		$rsnew = array();

		// Field ID
		// Field LocationId

		$tb_dailygross_sales->LocationId->SetDbValueDef($tb_dailygross_sales->LocationId->CurrentValue, NULL);
		$rsnew['LocationId'] =& $tb_dailygross_sales->LocationId->DbValue;

		// Field DateRange1
		$tb_dailygross_sales->DateRange1->SetDbValueDef(ew_UnFormatDateTime($tb_dailygross_sales->DateRange1->CurrentValue, 5), NULL);
		$rsnew['DateRange1'] =& $tb_dailygross_sales->DateRange1->DbValue;

		// Field MedicaidAmount
		$tb_dailygross_sales->MedicaidAmount->SetDbValueDef($tb_dailygross_sales->MedicaidAmount->CurrentValue, NULL);
		$rsnew['MedicaidAmount'] =& $tb_dailygross_sales->MedicaidAmount->DbValue;

		// Field MedicaidRx
		$tb_dailygross_sales->MedicaidRx->SetDbValueDef($tb_dailygross_sales->MedicaidRx->CurrentValue, NULL);
		$rsnew['MedicaidRx'] =& $tb_dailygross_sales->MedicaidRx->DbValue;

		// Field EpicRx
		$tb_dailygross_sales->EpicRx->SetDbValueDef($tb_dailygross_sales->EpicRx->CurrentValue, NULL);
		$rsnew['EpicRx'] =& $tb_dailygross_sales->EpicRx->DbValue;

		// Field CheckLog
		$tb_dailygross_sales->CheckLog->SetDbValueDef($tb_dailygross_sales->CheckLog->CurrentValue, NULL);
		$rsnew['CheckLog'] =& $tb_dailygross_sales->CheckLog->DbValue;

		// Field PayRollAmount
		$tb_dailygross_sales->PayRollAmount->SetDbValueDef($tb_dailygross_sales->PayRollAmount->CurrentValue, NULL);
		$rsnew['PayRollAmount'] =& $tb_dailygross_sales->PayRollAmount->DbValue;

		// Field KinaryAmount
		$tb_dailygross_sales->KinaryAmount->SetDbValueDef($tb_dailygross_sales->KinaryAmount->CurrentValue, NULL);
		$rsnew['KinaryAmount'] =& $tb_dailygross_sales->KinaryAmount->DbValue;

		// Field EnteredBy
		$tb_dailygross_sales->EnteredBy->SetDbValueDef($tb_dailygross_sales->EnteredBy->CurrentValue, NULL);
		$rsnew['EnteredBy'] =& $tb_dailygross_sales->EnteredBy->DbValue;

		// Field CreateDate
		$tb_dailygross_sales->CreateDate->SetDbValueDef(ew_UnFormatDateTime($tb_dailygross_sales->CreateDate->CurrentValue, 5), NULL);
		$rsnew['CreateDate'] =& $tb_dailygross_sales->CreateDate->DbValue;

		// Field DateRange2
		$tb_dailygross_sales->DateRange2->SetDbValueDef(ew_UnFormatDateTime($tb_dailygross_sales->DateRange2->CurrentValue, 5), NULL);
		$rsnew['DateRange2'] =& $tb_dailygross_sales->DateRange2->DbValue;

		// Call Row Updating event
		$bUpdateRow = $tb_dailygross_sales->Row_Updating($rsold, $rsnew);
		if ($bUpdateRow) {
			$conn->raiseErrorFn = 'ew_ErrorFn';
			$EditRow = $conn->Execute($tb_dailygross_sales->UpdateSQL($rsnew));
			$conn->raiseErrorFn = '';
		} else {
			if ($tb_dailygross_sales->CancelMessage <> "") {
				$_SESSION[EW_SESSION_MESSAGE] = $tb_dailygross_sales->CancelMessage;
				$tb_dailygross_sales->CancelMessage = "";
			} else {
				$_SESSION[EW_SESSION_MESSAGE] = "Update cancelled";
			}
			$EditRow = FALSE;
		}
	}

	// Call Row Updated event
	if ($EditRow) {
		$tb_dailygross_sales->Row_Updated($rsold, $rsnew);
	}
	$rs->Close();
	return $EditRow;
}
?>
<?php

// Page Load event
function Page_Load() {

	//echo "Page Load";
}

// Page Unload event
function Page_Unload() {

	//echo "Page Unload";
}
?>
